//
//  ZhuBaoController.m
//  DianDangDai
//
//  Created by bhf on 2017/12/28.
//  Copyright © 2017年 bhf. All rights reserved.
//

#import "ZhuBaoController.h"
#import "GuiJinShuCell.h"
@interface ZhuBaoController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) NSArray *array;
@property (nonatomic, strong) NSArray *array2;
@property (nonatomic, strong) NSArray *placeholder;

@end

@implementation ZhuBaoController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    _array = @[@"*品类",@"*类型",@"  颜色",@"  净度",@"  切工"];
    _array2 = @[@"*购买时间",@"*辅石",@"  辅石材质",@"  证书",@"  重量"];
    _placeholder = @[@"请输入购买时间",@"请选择",@"请输入数值",@"请输入证书",@"请输入重量"];
    self.title = @"填写物品信息";

    // Do any additional setup after loading the view.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 5;
    } else if (section == 1){
        return 6;
    } else {
        return 2;
    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *identfier;
    if (indexPath.section == 0) {
        switch (indexPath.row) {
            case 0:
                identfier = @"pinggu_cell_II";
                break;
            case 1:
                identfier = @"pinggu_cell_I";
                break;
            case 2:
                identfier = @"pinggu_cell_I";
                break;
            case 3:
                identfier = @"pinggu_cell_I";
                break;
            case 4:
                identfier = @"pinggu_cell_I";
                break;
            default:
                break;
        }
        
    } else if (indexPath.section == 1){
        switch (indexPath.row) {
            case 0:
                identfier = @"pinggu_cell_I";
                break;
            case 1:
                identfier = @"pinggu_cell_I";
                break;
            case 2:
                identfier = @"pinggu_cell_II";
                break;
            case 3:
                identfier = @"pinggu_cell_II";
                break;
            case 4:
                identfier = @"pinggu_cell_II";
                break;
            case 5:
                identfier = @"pinggu_cell_III";
                break;
           
            default:
                break;
        }
    } else if (indexPath.section == 2) {
        switch (indexPath.row) {
            case 0:
                identfier = @"pinggu_cell_II";
                break;
            case 1:
                identfier = @"pinggu_cell_II";
                break;
         
            default:
                break;
        }
    }
    GuiJinShuCell *cell = [tableView dequeueReusableCellWithIdentifier:identfier forIndexPath:indexPath];
    if (indexPath.section == 0) {
        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:_array[indexPath.row]];
        [string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
        cell.lab.attributedText = string;
        cell.tf1.placeholder = @"请选择";
        if (indexPath.row == 0) {
            cell.tf1.text = @"珠宝玉石";
        }
        cell.lab3.hidden = YES;
        
        
    } else if (indexPath.section == 1) {
        if (indexPath.row != 5) {
            NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:_array2[indexPath.row]];
            [string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
            cell.lab.attributedText = string;
            cell.tf1.placeholder = _placeholder[indexPath.row];
        
        }
        if (indexPath.row == 2 || indexPath.row == 3) {
            cell.lab3.hidden = YES;
        }
        if (indexPath.row == 4) {
            cell.lab3.text = @"克拉";
        }
    } else if (indexPath.section == 2) {
        if (indexPath.row == 0) {
            cell.lab.text = @"  描述";
            cell.tf1.placeholder = @"请描述您的物品";
            cell.lab3.hidden = YES;
        } else {
            NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"*购买价格"];
            [string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
            cell.lab.attributedText = string;
            cell.tf1.placeholder = @"请输入购买价格";
        }
        
    }
    
    
    // Configure the cell...
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 60;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return 0;
    } else {
        return 10;
    }
    
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
    view.backgroundColor = [UIColor colorWithHex:@"#f5f5f5"];
    return view;
}

- (IBAction)next:(UIButton *)sender {
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
